package com.example.musicapp.model;

import com.example.musicapp.base.BaseModel;
import com.example.musicapp.contract.ILoginContract;
import com.example.musicapp.network.HttpResponseListener;

import com.example.musicapp.utils.HttpUtils;




import java.util.HashMap;
import java.util.Map;



public class LoginModel extends BaseModel implements ILoginContract.LoginModel {
    @Override
    public void login(String username, String password, HttpResponseListener callBack) {
/*        System.out.println("看看这md5"+CommonUtils.hashKeyFormUrl(password));
        RequestBody body = new FormBody.Builder().add("phone",username).add("password",password).add("md5_password", CommonUtils.hashKeyFormUrl(password)).build();
        String url = "http://music.louis-ui.top"+"/login/cellphone";
        HttpUtils.sendOkHttpRequest(url, new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                try {
                    callBack.onSuccess(response.body().string());
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });*/
        String url = "http://music.gochiusa.top"+"/login/cellphone";

        Map<String, String> loginMap = new HashMap<>();
        loginMap.put("phone", username);
        loginMap.put("password", password);
        HttpUtils.sendPostData(url, loginMap, "UTF-8", callBack);

    }
}
